Skip to content

Conversation

@dtfranz
Copy link
Contributor

@dtfranz dtfranz commented Feb 6, 2026

Fixing some missing flags and godoc comments brought up via API review.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@netlify
Copy link

netlify bot commented Feb 6, 2026

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 66b75c9
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/698d861f3baa4b00099b8682
😎 Deploy Preview https://deploy-preview-2491--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dtfranz dtfranz changed the title ⚠ ClusterExtensionRevision API Updates ⚠ WIP: ClusterExtensionRevision API Updates Feb 6, 2026
@openshift-ci
Copy link

openshift-ci bot commented Feb 6, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tmshort for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dtfranz
Copy link
Contributor Author

dtfranz commented Feb 6, 2026

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 6, 2026
@dtfranz dtfranz changed the title ⚠ WIP: ClusterExtensionRevision API Updates ⚠️ WIP: ClusterExtensionRevision API Updates Feb 6, 2026
@dtfranz dtfranz marked this pull request as draft February 6, 2026 07:12
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 6, 2026
@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.72%. Comparing base (1624bed) to head (66b75c9).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2491      +/-   ##
==========================================
+ Coverage   69.82%   73.72%   +3.89%     
==========================================
  Files         102      102              
  Lines        8496     8497       +1     
==========================================
+ Hits         5932     6264     +332     
+ Misses       2091     1748     -343     
- Partials      473      485      +12     
Flag Coverage Δ
e2e 46.16% <0.00%> (-0.01%) ⬇️
experimental-e2e 54.05% <100.00%> (+41.15%) ⬆️
unit 57.98% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@pedjak pedjak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect additional validation tests to add, given that we added a few more restrictions/checks in this PR. Like for checking min/max size of given arrays, etc.

//
// Once set, even if empty, the phases field is immutable.
//
// Each phase in the list must have a unique name. The maximum number of phases is 20.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also set the min number of phases to 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, unless we can think of a genuinely useful reason to create a no-op CER? I can't think of one though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: Looks like we've intentionally built in the ability to have phases initially unset, and allow the normally immutable list to be updated once. If we want to preserve that, we can't set the minimum length to 1 with omitempty present. Removing omitempty removes our ability to leave it unset. Is it vital that we keep this in place?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we only use inline objects, it's ok to set a minimum. When we move to sharding, it could be that we'll want to create the ClusterExtensionRevision object first, then create the shards with the ownerref, then update the revision with the shard refs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the helm chunked secret implementation: https://github.com/operator-framework/helm-operator-plugins/blob/f1e4eaf3b3924d3339dda2eee7f4520c47fd6162/pkg/storage/chunked.go#L62-L90

There we precompute everything, then:

  1. Create the immutable index object with all of the chunk references pre-filled
  2. Create the immutable chunks with owner refs to the index

We can do the same with the CER right?

  1. Make its phases fully immutable
  2. Generate the phase object contents and figure out what the names are going to be so we can pre-fill references in the CER
  3. Generate the CER with the phase object references pre-filled
  4. Generate the phase objects with the CER ownerRef

That way:

  1. If we try to read the phases from the CER after 3, but before 4, we correctly get an error instead of incorrectly assuming there are no phases
  2. If the CER is deleted between 3 and 4, we'll end up putting an ownerref on the phase objects that for an object that is already deleted and garbage collect will automatically delete the phase objects.
  3. Phases are immutable and create-only and we don't have to handle errors that could occur on an attempt to update the phases.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2026
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the ClusterExtensionRevision API surface (Go types + generated CRDs/manifests) to address gaps identified during API review, primarily by tightening schema requirements and improving documentation.

Changes:

  • Make spec.lifecycleState and per-object collisionProtection required (removing CRD defaults).
  • Add/clarify schema constraints for inline phases (e.g., max phases/objects) and expand lifecycle/phase documentation.
  • Update operator-controller generator/tests and API validation tests to populate newly-required fields.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
manifests/experimental.yaml Updates experimental manifest schema/docs to reflect new required fields and constraints.
manifests/experimental-e2e.yaml Mirrors the experimental schema/doc updates for e2e manifests.
helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensionrevisions.yaml Updates the shipped Helm CRD for ClusterExtensionRevision with the new requirements/validations.
api/v1/clusterextensionrevision_types.go Source-of-truth API changes: required markers, added validations/limits, doc updates.
api/v1/clusterextensionrevision_types_test.go Adds/updates envtest-backed validity/immutability tests for the new schema.
api/v1/validation_test.go Updates validation tests to set LifecycleState where required.
internal/operator-controller/applier/boxcutter.go Ensures generated revision objects always set CollisionProtection.
internal/operator-controller/applier/boxcutter_test.go Updates expectations to include CollisionProtection in generated revision objects.
Comments suppressed due to low confidence (1)

api/v1/clusterextensionrevision_types.go:60

  • LifecycleState is marked +required and the CRD now requires it, but the Go JSON tag still uses omitempty. This is inconsistent with other required fields in this repo (which typically omit omitempty) and can cause marshaling to silently drop the field when the zero value is present, producing invalid objects. Consider removing omitempty (and update any constructors/tests that currently rely on omitting the field, e.g. helpers that build ClusterExtensionRevisionSpec{Revision: ...} without a lifecycleState).
	// +required
	// +kubebuilder:validation:Enum=Active;Archived
	// +kubebuilder:validation:XValidation:rule="oldSelf == 'Active' || oldSelf == 'Archived' && oldSelf == self", message="cannot un-archive"
	LifecycleState ClusterExtensionRevisionLifecycleState `json:"lifecycleState,omitempty"`


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

//
// Once set, even if empty, the phases field is immutable.
//
// Each phase in the list must have a unique name. The minimum number of inlinePhases is 1, and the maximum is 20.
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says “The minimum number of inlinePhases is 1”, but phases is still declared +optional and existing tests/validations allow phases to be unset or empty. This doc looks incorrect/misleading; either enforce a minimum (e.g., MinItems=1 when phases is set / required) or update the comment to reflect that zero phases is allowed.

Suggested change
// Each phase in the list must have a unique name. The minimum number of inlinePhases is 1, and the maximum is 20.
// Each phase in the list must have a unique name. The maximum number of inlinePhases is 20.

Copilot uses AI. Check for mistakes.
Comment on lines +135 to 139
// +required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern=`^[a-z]([-a-z0-9]*[a-z0-9])?$`
// +kubebuilder:validation:XValidation:rule=`!format.dns1123Label().validate(self).hasValue()`,message="the value must consist of only lowercase alphanumeric characters and hyphens, and must start with an alphabetic character and end with an alphanumeric character."
Name string `json:"name"`
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new XValidation uses format.dns1123Label() which (depending on Kubernetes/CEL semantics) may allow leading digits, while the error message implies an alphabetic first character. If the intent is to require a leading letter (as the previous regex did), consider switching back to a regex-based rule (or OpenAPI pattern) that enforces the leading-letter constraint, or update the message/tests to match the actual accepted values.

Copilot uses AI. Check for mistakes.
//
// Allowed values are: "Prevent", "IfNoController", and "None".
//
// When set to "Prevent" (the default), the operator only manages objects it created itself.
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CollisionProtection is now required, but the doc still says “When set to "Prevent" (the default)…”. Since the API no longer defaults this field, this wording is misleading—either remove the “(the default)” phrasing or reintroduce explicit defaulting behavior.

Suggested change
// When set to "Prevent" (the default), the operator only manages objects it created itself.
// When set to "Prevent", the operator only manages objects it created itself.

Copilot uses AI. Check for mistakes.
Comment on lines +177 to 180
// +required
// +kubebuilder:validation:Enum=Prevent;IfNoController;None
// +optional
CollisionProtection CollisionProtection `json:"collisionProtection,omitempty"`
}
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CollisionProtection is marked +required, but the JSON tag still includes omitempty. As with LifecycleState, this can lead to marshaled revisions that omit a required field when the zero value is present. Consider removing omitempty to match repo conventions for required fields.

Copilot uses AI. Check for mistakes.
Fixing some missing flags and godoc comments brought up via API review.

Signed-off-by: Daniel Franz <[email protected]>
Copilot AI review requested due to automatic review settings February 12, 2026 07:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// +required
// +kubebuilder:validation:Enum=Active;Archived
// +kubebuilder:validation:XValidation:rule="oldSelf == 'Active' || oldSelf == 'Archived' && oldSelf == self", message="cannot un-archive"
LifecycleState ClusterExtensionRevisionLifecycleState `json:"lifecycleState,omitempty"`
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lifecycleState is marked +required but the JSON tag still uses omitempty, which is inconsistent with other required API fields in this repo (e.g. CatalogFilter.PackageName). Consider removing omitempty so clients using typed structs can’t accidentally omit a required field during marshaling.

Suggested change
LifecycleState ClusterExtensionRevisionLifecycleState `json:"lifecycleState,omitempty"`
LifecycleState ClusterExtensionRevisionLifecycleState `json:"lifecycleState"`

Copilot uses AI. Check for mistakes.
// +required
// +kubebuilder:validation:Enum=Prevent;IfNoController;None
// +optional
CollisionProtection CollisionProtection `json:"collisionProtection,omitempty"`
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

collisionProtection is now +required, but the field tag is still json:"collisionProtection,omitempty". For required fields elsewhere in the API, the JSON tag typically omits omitempty; consider removing it here to match the required/optional contract and avoid silently dropping an unset value during marshaling.

Suggested change
CollisionProtection CollisionProtection `json:"collisionProtection,omitempty"`
CollisionProtection CollisionProtection `json:"collisionProtection"`

Copilot uses AI. Check for mistakes.
Comment on lines +694 to +695
characters and hyphens, and must start with an alphabetic
character and end with an alphanumeric character.
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema description for phases[].name says phase names “start and end with an alphanumeric character”, but the CEL validation message says the name must start with an alphabetic character. Please make these consistent to avoid confusing API consumers (either adjust the description or the validation/message).

Suggested change
characters and hyphens, and must start with an alphabetic
character and end with an alphanumeric character.
characters and hyphens, and must start and end with an
alphanumeric character.

Copilot uses AI. Check for mistakes.
Comment on lines +733 to +734
characters and hyphens, and must start with an alphabetic
character and end with an alphanumeric character.
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema description for phases[].name says phase names “start and end with an alphanumeric character”, but the CEL validation message says the name must start with an alphabetic character. Please make these consistent to avoid confusing API consumers (either adjust the description or the validation/message).

Suggested change
characters and hyphens, and must start with an alphabetic
character and end with an alphanumeric character.
characters and hyphens, and must start and end with an
alphanumeric character.

Copilot uses AI. Check for mistakes.
Comment on lines +138 to +147
"inlinePhases must have no more than 20 phases": {
spec: ClusterExtensionRevisionSpec{
LifecycleState: ClusterExtensionRevisionLifecycleStateActive,
Revision: 1,
Phases: make([]ClusterExtensionRevisionPhase, 21),
},
valid: false,
},
"inlinePhases entries must have no more than 50 objects": {
spec: ClusterExtensionRevisionSpec{
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test case names refer to inlinePhases, but the API field is spec.phases. Renaming these cases would make failures easier to interpret and keep terminology consistent with the API surface.

Copilot uses AI. Check for mistakes.
Comment on lines +121 to +122
characters and hyphens, and must start with an alphabetic
character and end with an alphanumeric character.
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema description for phases[].name says phase names “start and end with an alphanumeric character”, but the CEL validation message says the name must start with an alphabetic character. Please make these consistent to avoid confusing API consumers (either adjust the description or the validation/message).

Suggested change
characters and hyphens, and must start with an alphabetic
character and end with an alphanumeric character.
characters and hyphens, must start and end with an alphanumeric
character, and be no longer than 63 characters.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants